﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace UCenter.Core.Common
{
    public static class AppSettings
    {
        #region Static Properties

        /// <summary>
        /// Database connection string
        /// </summary>
        public static string ConnectionString
        {
            get
            {
                return GetValue("RepositoryConnectionName");
            }
        }

        public static string FromEmailAddress
        {
            get
            {
                return GetValue("UCenter.FromAddress");
            }
        }

        public static string MainDomain
        {
            get { return GetValue("UCenter.MainDomain"); }
        }

        public static string DefaultCulture
        {
            get
            {
                return GetValue("UCenter.DefaultCulture");
            }
        }

        #endregion

        #region Static Methods

        public static string GetValue(string key)
        {
            string value = ConfigurationManager.AppSettings[key];

            if (string.IsNullOrEmpty(value))
            { 
                throw new InvalidOperationException(string.Format("The application setting key '{0}' is not set",key));
            }

            return value;
        }

        #endregion
    }
}
